package com.scau.clothes.sale.service;

import com.alipay.api.response.AlipayTradeRefundResponse;
import com.baomidou.mybatisplus.extension.service.IService;
import com.scau.clothes.sale.model.dto.ExchangeDto;
import com.scau.clothes.sale.model.dto.ReturnDto;
import com.scau.clothes.sale.model.entity.Sale;
import com.scau.clothes.sale.model.entity.SaleClothes;
import com.scau.clothes.sale.model.vo.PieDataVo;
import com.scau.clothes.stock.model.entity.ClothesNorm;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.math.BigDecimal;
import java.util.List;

public interface SaleService extends IService<Sale> {

    /**
     * 开始新的销售
     */
    Sale makeNewSale();

    /**
     * 实例化SaleItem
     * @param clothesNorm 商品对象
     * @param quantity 数量
     */
    void makeLineItem(ClothesNorm clothesNorm, int quantity);

    /**
     * 结束订单商品录入
     * @return 总金额
     */
    BigDecimal endSale();

    /**
     * 订单支付(现金)
     * @param cashTendered 付款金额
     * @return 找零
     */
    BigDecimal makePaymentByCash(Sale sale, BigDecimal cashTendered);

    /**
     * 订单支付(支付宝)
     */
    void makePaymentByAlipay(Long saleId, HttpServletResponse httpResponse) throws Exception;

    /**
     * 回调接口
     */
    String payNotify(HttpServletRequest request) throws Exception;

    /**
     * 退款接口
     */
    Boolean returnBack(ReturnDto returnDto) throws Exception;

    /**
     * 换货接口
     */
    Boolean exchange(ExchangeDto exchangeDto);

    /**
     * 订单取消
     */
    Sale cancelSale(Sale sale);

    List<Sale> listAllSale(Sale sale);

    BigDecimal getClothesNormDiscountPrice(BigDecimal price);

}
